package com.paper.tiger.easy.rpc.center.common;

import com.paper.tiger.easy.rpc.center.service.BaseService;
import com.paper.tiger.easy.rpc.center.service.RegisterRequestService;
import com.paper.tiger.easy.rpc.center.service.SelectRequestService;
import com.paper.tiger.easy.rpc.core.ServerType;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * [简要描述]:
 * [详细描述]:
 *
 * @author ZouHaiBo
 * @version 1.0, 2021/6/15 20:00
 * @since JDK 1.8
 */
public class RegisterObject
{

    public static final Map<String, Object> SERVICE_MAP = new HashMap<>();

    /**
     * 注册服务
     */
    public void registerService(){

        SERVICE_MAP.put(ServerType.REGISTER_REQUEST.getRegisterName(),new RegisterRequestService());
        SERVICE_MAP.put(ServerType.SELECT_REQUEST.getRegisterName(),new SelectRequestService());
        SERVICE_MAP.put("baseServerThreadPool", new ThreadPoolExecutor(1, 2, 60,
                TimeUnit.SECONDS, new LinkedBlockingDeque<>(1000), r -> new Thread(r,"baseServiceThread"),new ThreadPoolExecutor.AbortPolicy()));

    }

}
